const webpack = require('webpack');
// const reactConfig = require('./react/webpack.dll.config.js');
const reduxConfig = require('./redux/webpack.dll.config.js');
const mobxConfig = require('./mobx/webpack.dll.config.js');
const babelConfig = require('./babel/webpack.dll.config.js');

const arrConfig = [
    // reactConfig,
    reduxConfig,
    mobxConfig,
    babelConfig,
];

const run = (arr, index) => {
    if (index >= arr.length) {
        return;
    }
    const compiler = webpack(arr[index]);

    compiler.run((err, stats) => {
        if (err) {
            return console.error(err);
        }

        const jsonStats = stats.toJson();

        if (jsonStats.errors.length > 0) {
            jsonStats.errors.forEach(function (element) {
                console.log(element);
            }, this);
        }
        run(arr, index + 1);
        return 0;
    });
};

run(arrConfig, 0);
